const urlPrefix = getApp().globalData.urlPrefix;
Page({  
  data: {  
    "bhList":[],
    "id":""
  },  
  
  // 页面加载时调用后端接口  
  onLoad: function () {  
    this.getDataFromBackend();  
  },  
  onShow: function(){
    this.getDataFromBackend();
  },
  
  // 调用后端接口并处理返回值  
  getDataFromBackend: function () {  
    const that = this; // 将 this 绑定到 Page 对象上  
    wx.request({  
      url: urlPrefix + '/tongji/listBingHao', 
      method: 'POST', // 或者 'POST'  
      ContentType:'application/json',
      data:{},
      success: function (res) {  
        that.setData({
          "bhList":res.data.list
        })
      },  
      fail: function (error) {  
        // 处理请求失败的情况  
        console.log('请求失败:', error);  
      },  
    });  
  },  

  addRecord:function(e){
       var obj = e.currentTarget.dataset.value; 
       var id = obj.id;
       var bh_name = obj.bhName;
       var bh_floor = obj.bhFloor;
       var bh_belong_to = obj.bhBelongTo;
        wx.navigateTo({
      url: '/pages/addrecord/addrecord?id='+id+'&bh_name='+bh_name+'&bh_floor='+bh_floor+'&bh_belong_to='+bh_belong_to,
    })
  },

  detail:function(e){
    var obj = e.currentTarget.dataset.value; 
    var bh_id = obj.id;
    var user_open_id = obj.bhBelongTo;
     wx.navigateTo({
   url: '/pages/recordDetail/recordDetail?bh_id='+bh_id+'&user_open_id='+user_open_id,
 })
  },

  addBingHao:function(){
    wx.navigateTo({
      url: '/pages/binghao/binghao',
    })
  }
});